package com.loveyukari.service;

import java.io.IOException;

import org.springframework.stereotype.Service;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketMessage;
import org.springframework.web.socket.WebSocketSession;

import com.loveyukari.support.SocketResult;

/**
*
*yangshaohua
*2017年10月11日上午10:21:50
**/
@Service
public class WebSocketService {
	
	public void sendMessage(WebSocketSession session,String msg) throws IOException{
		TextMessage textMessage = new TextMessage(msg);
		sendMessage(session, textMessage);
	}
	
	private void sendMessage(WebSocketSession session,WebSocketMessage<String> message) throws IOException{
		session.sendMessage(message);
	}
	
	public void sendMessage(WebSocketSession session,SocketResult socketResult) throws IOException{
		sendMessage(session, socketResult.toString());
	}

}
